﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views.popups.stolengem {
    import flash.events.*;
    import reprise.controls.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.*;
    import net.wooga.pets.views.popups.*;
    import net.wooga.pets.constants.*;

    public class StolenGemPopupMediator extends AbstractPopupMediator {

        public var user:UserModel;
        public var friends:FriendsModel;

        override public function onRegister():void{
            super.onRegister();
            var _local1 = "showcardGothicFont";
            addLabel(("title " + _local1), "pow_leave_message", {friendsname:this.friendsName});
            this.addMessage("cry", "pow_stealgem_actionlink");
            this.addMessage("loser", "pow_stealgem_actionlink");
            this.addMessage("sleeping", "pow_stealgem_actionlink");
            this.addMessage("stealer", "pow_stealgem_actionlink");
        }
        private function addMessage(_arg1:String, _arg2:String):void{
            var _local3:Object = {friendsname:this.friendsName, symbol:this.view.data.symbol};
            var _local4:String = language.getTextByKey((("pow_stealgem_" + _arg1) + "_storytitle"), _local3);
            var _local5:String = language.getTextByKey("pow_on_friends_wall", _local3);
            var _local6:LabelButton = this.view.addMessage(("StolenGemIcon_" + _arg1), _local4, _local5).button;
            _local6.setData({id:_arg1, link:_arg2});
            eventMap.mapListener(_local6, MouseEvent.CLICK, this.onMessageClicked, MouseEvent);
        }
        override protected function handlePostOnWallResult(_arg1:Boolean, _arg2:String):void{
            if (((_arg1) && ((_arg2 == GameConstants.STOLEN_GEM)))){
                close();
            };
        }
        private function onMessageClicked(_arg1:MouseEvent):void{
            var _local2:Object = _arg1.target.data();
            var _local3:String = this.friends.getFriend(this.user.visitingFriendID).first_name;
            var _local4:Object = {type:GameConstants.STOLEN_GEM, id:_local2.id, link:_local2.link, friendsname:_local3, symbol:this.view.data.symbol};
            var _local5:InfoEvent = new InfoEvent(EventConstants.POST_ON_WALL, null, _local4);
            dispatch(_local5);
        }
        private function get view():StolenGemPopupView{
            return ((viewComponent as StolenGemPopupView));
        }
        private function get friendsName():String{
            return (this.friends.getFriend(this.user.visitingFriendID).first_name);
        }

    }
}//package net.wooga.pets.views.popups.stolengem 
